<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" name="flowuser" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">申请时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="created_at" id="created_at" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">流程单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="sericnum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">付款对象</label>
                        <div class="layui-input-block">
                            <input type="text" name="fuer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">款项类型</label>
                        <div class="layui-input-block">
                            <div id="zhiqilei" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">票据状态：</label>
                        <div class="layui-input-block">
                            <select id="statename" name="statename" lay-filter="statename">
                                <option value="">请选择</option>
                                <option value="已收票">已收票</option>
                                <option value="部分收票">部分收票</option>
                                <option value="未收票">未收票</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-block">
                            <select id="status" name="status" lay-filter="status">
                                <option value="">请选择</option>
                                <option value="1">流程（审批通过）</option>
                                <option value="0">流程（审批中）</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
<!--        <button class="layui-btn layui-btn-primary outbut" onclick="auth_but_func_fan('返款登记')">返款登记</button>-->
    </div>
</script>
<script>
    var deafault_created_at = getRecentThreeMonthsDateRange();
    $("#created_at").val(deafault_created_at);

    var param_listid = getQueryVariable('listid') || 0;
    if(param_listid > 0){
        deafault_created_at = '';
        $("#created_at").val(deafault_created_at);
    }


    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('付款明细');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_hou_dayzhi_detail),where: {created_at:deafault_created_at,listid:param_listid}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xmselect_dan('zhiqilei', res.data.zhiqilei, res.data.is_zhiqilei, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'sericnum',title:'流程单号',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../hou_dayzhi/show.php?id='+d.id+'\');">'+d.sericnum+'</span>';
                    }}
                ,list_bill_cols_str
                ,{field: 'fuer', title: '付款对象'}
                ,{field: 'bankzhang', title: '账户名称'}
                ,{field: 'banknum', title: '账号'}
                ,{field: 'bankname', title: '开户行'}
                ,{field: 'incdaotype_name', title: '支付方式'}
                ,{field: 'zhiqilei_name', title: '款项类型'}
                ,{field: 'listmoney', title: '本次付款金额(元)A',totalRow: true}
                ,{field: 'listexplain', title: '款项说明'}
                ,{field:'statename',title:'票据状态',templet: function(d){
                        if(d.statename == '已收票'){
                            return '<span class="colorlv">'+d.statename+'</span>';
                        }else if(d.statename == '部分收票'){
                            return '<span class="colorhuang">'+d.statename+'</span>';
                        }else if(d.statename == '未收票'){
                            return '<span class="colorhong">'+d.statename+'</span>';
                        }else{
                            return d.statename;
                        }
                    }}
                ,{field: 'yifufee', title: '累计已收票金额(元)B',totalRow: true}
                ,{field: 'daifufee', title: '待收票金额(元)A-B',totalRow: true}
                ,{field: 'difee', title: '本次关联进项票金额(元)',totalRow: true}
                ,{field: 'flowuser', title: '申请人'}
                ,{field: 'created_at', title: '申请日期'}
            ]]
            , done: function (res) {
                $(".layui-table-page").addClass('layui-hide');
                soulTable.render(this);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_fan(buttitle){
        var checkStatus = layui.table.checkStatus('datalist').data;
        var idArr = [];
        var isshen = false;
        for(var i=0;i<checkStatus.length;i++){
            if(checkStatus[i].status == 0){
                isshen = true;
            }
            idArr.push(checkStatus[i].listid)
        }

        if(idArr.length < 1){
            facade.error(buttitle + "：请选择数据");return false;
        }
        if(isshen){
            facade.error(buttitle + "：请选择审批通过的数据");return false;
        }

        openPageEdit('fan.php?close=1&ids='+idArr.join(','), '770px', '490px');
    }


</script>
</body>
</html>
